package com.holly.unit.deform.designer.core.table;

import cn.hutool.core.util.StrUtil;
import com.holly.unit.deform.designer.context.FormDesignerDbContext;
import com.holly.unit.deform.designer.service.DdlService;
import com.holly.unit.deform.designer.util.DDLUtil;

/**
 * 类描述: 数据定义语言语句执行器
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/8/2 15:34
 */
public class DdlExecutor {

    private static DdlService ddlService = FormDesignerDbContext.ddlService();

    private DdlExecutor() {
        throw new UnsupportedOperationException("DdlExecutor类无法实例化");
    }

    public static void execute(String ddl) {

        if (StrUtil.isEmpty(ddl)) {
            return;
        }

        // 创建表语句
        if (DDLUtil.isCreate(ddl)) {
            ddlService.createTable(ddl);
        }

        // 修改表语句
        if (DDLUtil.isAlert(ddl)) {
            ddlService.alertTable(ddl);
        }
    }
}
